﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Esb.Soa.Contract
{
    public class CallServiceContract
    {
        public string MethodName
        {
            get { return "CallServiceByEsb"; }
        }

        public CallServiceRequest Request { get; set; }

        public CallServiceResponse Response { get; set; }
    }


    public class CallServiceRequest
    {
        /// <summary>
        /// 调用方应用Id
        /// </summary>
        public int CallerId { get; set; }

        /// <summary>
        /// 环境配置
        /// </summary>
        public EnvironmentType Environment { get; set; }

        /// <summary>
        /// 服务的路由，即契约全名
        /// </summary>
        public string ServiceRouteName { get; set; }

        /// <summary>
        /// 请求的方法
        /// </summary>
        public string Method { get; set; }

        /// <summary>
        /// WCF中的哪一个服务
        /// </summary>
        public string ServiceEntity { get; set; }

        /// <summary>
        /// 真实的请求体字符串
        /// </summary>
        public string RequestBody { get; set; }

        /// <summary>
        /// 支持http动词
        /// </summary>
        public string HttpVerb { get; set; }

        /// <summary>
        /// 支持手动输入服务路由
        /// </summary>
        public string ServiceUrl { get; set; }

        ///// <summary>
        ///// 支持输入资源Id
        ///// </summary>
        //public object ResourceId;
    }

    /// <summary>
    /// 环境类型
    /// </summary>
    public enum EnvironmentType
    {
        //开发
        Dev,

        //测试
        Test,

        //预发布
        Uat,

        //生产
        Prd
    }

    public class CallServiceResponse
    {
        /// <summary>
        /// 返回体字符串
        /// </summary>
        public string ResponseBody { get; set; }

        /// <summary>
        /// 服务的AppId
        /// </summary>
        public int ServiceApplicationId { get; set; }

        /// <summary>
        /// 返回的状态码
        /// </summary>
        public Message ReturnMessage { get; set; }
    }

    public class Message
    {
        public string Code { get; set; }

        public string MessageText { get; set; }
    }
}
